<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH. 'controllers/layout.php');

class Checkout extends Layout
{
	public function __construct()
	{
		parent::__construct();
	}
	
	public function index()
	{
		$baseurl = base_url();
		$table = 'tbl_customers';
		$data = array(
				'full_name' => $this->input->post('fullname'),
				'pid' => $this->input->post('productid'),
				'phone' => $this->input->post('phone'),
				'address' => $this->input->post('address'),
				'status' => 0,
				'created' => date('Y-m-d H:i:s'),
		);
		$result = $this->utility_model->insert($table , $data);
		if($result){
			echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
			<script>
			alert('Bạn đã mua hàng thành công chúng tôi sẽ sớm liên hệ sớm nhất với bạn !');
			window.open('{$baseurl}','_self');
			</script>";
		}else {
			log_message('error', 'Some variable did not contain a value.');
		}
	}
	
}